package o;

import android.content.Context;
import android.util.SparseArray;
import androidx.annotation.NonNull;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;

public class cib {
    private static int ʽ = 0;
    private static final Map<String, Class<? extends CardBean>> ˊ = new HashMap();
    private static SparseArray<Class<? extends cih>> ˋ = new SparseArray();
    private static final Map<Integer, Class<? extends CardBean>> ˎ = new HashMap();
    private static SparseArray<Class<? extends cie>> ˏ = new SparseArray();
    private static HashMap<String, Integer> ॱ = new HashMap();

    public static cie ˋ(@NonNull Context context, int i) {
        cie o_cie;
        Throwable e;
        Throwable th;
        Class ˊ = ˊ(i);
        if (ˊ == null) {
            ccn.ˏ.ˊ("CardFactory", "Don't support card type:" + i);
            return null;
        }
        try {
            o_cie = (cie) ˊ.getConstructor(new Class[]{Context.class}).newInstance(new Object[]{context});
            try {
                o_cie.ˎ = i;
                return o_cie;
            } catch (NoSuchMethodException e2) {
                e = e2;
                ccn.ˏ.ˊ("CardFactory", "createNode error, card type:" + i, e);
                return o_cie;
            } catch (SecurityException e3) {
                e = e3;
                ccn.ˏ.ˊ("CardFactory", "createNode error, card type:" + i, e);
                return o_cie;
            } catch (InstantiationException e4) {
                e = e4;
                ccn.ˏ.ˊ("CardFactory", "createNode error, card type:" + i, e);
                return o_cie;
            } catch (IllegalAccessException e5) {
                e = e5;
                ccn.ˏ.ˊ("CardFactory", "createNode error, card type:" + i, e);
                return o_cie;
            } catch (IllegalArgumentException e6) {
                e = e6;
                ccn.ˏ.ˊ("CardFactory", "createNode error, card type:" + i, e);
                return o_cie;
            } catch (InvocationTargetException e7) {
                e = e7;
                ccn.ˏ.ˊ("CardFactory", "createNode error, card type:" + i, e);
                return o_cie;
            }
        } catch (Throwable e8) {
            th = e8;
            o_cie = null;
            e = th;
            ccn.ˏ.ˊ("CardFactory", "createNode error, card type:" + i, e);
            return o_cie;
        } catch (Throwable e82) {
            th = e82;
            o_cie = null;
            e = th;
            ccn.ˏ.ˊ("CardFactory", "createNode error, card type:" + i, e);
            return o_cie;
        } catch (Throwable e822) {
            th = e822;
            o_cie = null;
            e = th;
            ccn.ˏ.ˊ("CardFactory", "createNode error, card type:" + i, e);
            return o_cie;
        } catch (Throwable e8222) {
            th = e8222;
            o_cie = null;
            e = th;
            ccn.ˏ.ˊ("CardFactory", "createNode error, card type:" + i, e);
            return o_cie;
        } catch (Throwable e82222) {
            th = e82222;
            o_cie = null;
            e = th;
            ccn.ˏ.ˊ("CardFactory", "createNode error, card type:" + i, e);
            return o_cie;
        } catch (Throwable e822222) {
            th = e822222;
            o_cie = null;
            e = th;
            ccn.ˏ.ˊ("CardFactory", "createNode error, card type:" + i, e);
            return o_cie;
        }
    }

    public static <T extends cie> void ˎ(String str, Class<T> cls) {
        int i = ʽ;
        ʽ = i + 1;
        ॱ.put(str, Integer.valueOf(i));
        ˏ.put(i, cls);
    }

    public static <T extends cie> void ˎ(String str, Class<T> cls, Class<? extends cih> cls2) {
        int i = ʽ;
        ʽ = i + 1;
        ॱ.put(str, Integer.valueOf(i));
        ˏ.put(i, cls);
        ˋ.put(i, cls2);
    }

    public static <T extends CardBean> void ˊ(String str, Class<T> cls) {
        ˊ.put(str, cls);
    }

    public static <T extends CardBean> void ˏ(String str, Class<T> cls, Class<? extends CardBean> cls2) {
        ˊ.put(str, cls);
        ˎ.put(Integer.valueOf(ˏ(str)), cls2);
    }

    public static int ˏ() {
        return ॱ.size();
    }

    public static int ˏ(String str) {
        if (str != null) {
            Integer num = (Integer) ॱ.get(str.toLowerCase(Locale.US));
            if (num != null) {
                return num.intValue();
            }
        }
        return -1;
    }

    public static Class<? extends cie> ˊ(int i) {
        return (Class) ˏ.get(i);
    }

    public static Class<? extends cih> ˏ(int i) {
        return (Class) ˋ.get(i);
    }

    public static Class<? extends CardBean> ˊ(String str) throws InstantiationException {
        Class<? extends CardBean> cls = (Class) ˊ.get(str);
        if (cls != null) {
            return cls;
        }
        throw new InstantiationException("CardBean class not found, method:" + str);
    }

    public static Class<? extends CardBean> ॱ(Integer num) throws InstantiationException {
        Class<? extends CardBean> cls = (Class) ˎ.get(num);
        if (cls != null) {
            return cls;
        }
        throw new InstantiationException("CardBean class not found, method:" + num);
    }
}
